home *** CD-ROM | disk | FTP | other *** search
Text File | 1991-08-29 | 3.0 KB | 75 lines | [TEXT/ttxt] |
- # NewOpenSelection - replacement "Open Selection" script supporting file searching, backup and remember
-
- Set ScriptName "{0}" # save the script's name
- Set FileName "`TypeFile -q "{Active}".§ ≥≥ Dev:Null`"
- If ({FileName} != "")
- Open "{FileName}" ∑∑ Dev:Null
- Set OpenStatus {Status}
- If ({OpenStatus} == 0)
- # the Open was successful - perform the backup and remember chores
- ReadOnlyStatus "{Active}" ∑∑ Dev:Null # test if this is a read-only file
- If ({Status} == 0)
- Set LeafName "`ParseFileName -l "{Active}"`" # get the file's leafname
- Duplicate -y "{Active}" "{Backup}" ∑∑ "{Worksheet}" || Beep # create the backup file
-
- # Delete all the old "Remember" backup files
- For i in `Begin; Files -f "{Backup}{LeafName}".[0-9]+; End ≥ Dev:Null`
- Delete "{i}"
- End # For i
- End # If {OpenStatus}
- Else
- If ({OpenStatus} == 2)
- # the file was not found in the current directory: search for matching files
- Set FileName "`TypeFile -q "{Active}".§ ≥≥ Dev:Null`"
- Set FoundAny 0 # initialize
- Delete NewOpenSelection.temp ∑∑ Dev:Null
- If (("{#}" == 1) && ("{1}" == "-a"))
- # perform an all-colume search
- For i in `Volumes ≥≥ Dev:Null`
- WhereIs -c -s "{i}" {FileName} >> NewOpenSelection.temp ≥≥ Dev:Null
- If ({Status} == 0)
- Set FoundAny 1 # signal that at least one match was found
- End # If {Status}
- End # For i
- Else
- # search only MPW volume
- Set i `Volumes "{MPW}" ≥≥ Dev:Null`
- WhereIs -c -s "{i}" {FileName} >> NewOpenSelection.temp ≥≥ Dev:Null
- If ({Status} == 0)
- Set FoundAny 1 # signal that at least one match was found
- End # If {Status}
- End # If {#}
- If ({FoundAny})
- Set SelName `Begin; GetListItem -m "Open which file:" -s < NewOpenSelection.temp; Set ListStatus {Status}; End` ≥≥ Dev:Null
- Delete NewOpenSelection.temp ∑∑ Dev:Null
- If ({ListStatus} == 0)
- Open {SelName} ∑∑ Dev:Null
- Set OpenStatus {Status}
- If ({OpenStatus} == 0)
- # the Open was successful - perform the backup and remember chores
- ReadOnlyStatus "{Active}" ∑∑ Dev:Null # test if this is a read-only file
- If ({Status} == 0)
- Set LeafName "`ParseFileName -l "{Active}"`" # get the file's leafname
- Duplicate -y "{Active}" "{Backup}" ∑∑ "{Worksheet}" || Beep # create the backup file
-
- # Delete all the old "Remember" backup files
- For i in `Begin; Files -f "{Backup}{LeafName}".[0-9]+; End ≥ Dev:Null`
- Delete "{i}"
- End # For i
- End # If {Status}
- Else
- Alert "{ScriptName}:∂nUnable to open file {SelName}."
- End # If {OpenStatus}
- End # If {ListStatus}
- Else
- Alert "{ScriptName}:∂nNo files matching {FileName} were found."
- End # If FoundAny
- Else
- Alert "{ScriptName}:∂nUnable to open file {FileName}."
- End # If {OpenStatus}
- End # If {OpenStatus}
- Else
- Alert "{ScriptName}:∂nThere is no selection"
- End # If {FileName}
-
- # end of NewOpenSelection